<form [formGroup]="form"  class="great-form" (ngSubmit)="submitForm()">
  <div class="great-form-group">
    <label>最多10个字数:</label>
    <div class="great-input">
      <input type="text"  class="input" formControlName="strLength"><span [innerHtml]="'this.validator.strLength({maxLength:10})'"></span>
      <div class="great-form-error-text" *ngIf="form.get('strLength').dirty && form.get('strLength').errors">最多10个字数！</div>
    </div>
  </div>
  <div class="great-form-group">
    <label>必须10个字数:</label>
    <div class="great-input">
      <input type="text"  class="input" formControlName="strLength1"><span [innerHtml]="'this.validator.strLength({length:10})'"></span>
      <div class="great-form-error-text" *ngIf="form.get('strLength1').dirty && form.get('strLength1').errors">必须10个字数！</div>
    </div>
  </div>
  <div class="great-form-group">
    <label>最少10个字数:</label>
    <div class="great-input">
      <input type="text"  class="input" formControlName="strLength2"><span [innerHtml]="'this.validator.strLength({minLength:10})'"></span>
      <div class="great-form-error-text" *ngIf="form.get('strLength2').dirty && form.get('strLength2').errors">最少10个字数！</div>
    </div>
  </div>
  <div class="great-form-group">
    <label>5-10个字数:</label>
    <div class="great-input">
      <input type="text"  class="input" formControlName="strLength3"><span [innerHtml]="'this.validator.strLength({minLength:10, maxLength:10})'"></span>
      <div class="great-form-error-text" *ngIf="form.get('strLength3').dirty && form.get('strLength3').errors"> 5-10个字数  </div>
    </div>
  </div>
  <div class="great-form-group">
    <label>指定错误消息:</label>
    <div class="great-input">
      <input type="text"  class="input" formControlName="strLength4">
      <span [innerHtml]="'this.validator.strLength({minLength:5, errorMsg: \'最少输入5个字数\'})'"></span>
      <span [innerHtml]="'this.validator.strLength({maxLength:10, errorMsg: \'最多输入10个字数\'})'"></span>
      <div class="great-form-error-text" *ngIf="form.get('strLength4').dirty && form.get('strLength4').errors"> {{form.get('strLength4').errors.pattern.error}}  </div>
    </div>
  </div>
  <div class="great-form-group">
    <div class="great-form-bottom">
      <button type="submit">保 存</button>
    </div>
  </div>
</form>
